package cn.ruituo.adv2;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class MapTest {
    public static void main(String[] args) {
        //二维结构
        Map<String,String> map=new HashMap<>();
        map.put("clsName","java72");
        map.put("renshu","27");
        map.put("beginTime","10-18");
        map.put("zuishuai","hutao");
        map.put("zuigao","zhaojishan");
        map.put("shou","qiaoqiao");
        map.put("shou","yanglongfei");
        map.put("dog","狗");
        map.put("cat","猫");
        map.put("fat",null);
        System.out.println(map.size());
        System.out.println(map);
        System.out.println(">>>>>>>>>>遍历>>>>>>>>>>>>>");
        //方法1：
        Set<String> keys = map.keySet();//键的集合
        for(String k:keys){
            System.out.println(k+"="+map.get(k));
        }
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>");
        Scanner in=new Scanner(System.in);
        System.out.println("输入key:");
        String key=in.next();
        if (!map.containsKey(key)) {
            System.out.println("没有这个key");
        }else{
            System.out.println("对应的value是："+map.get(key));
        }
        //String value=map.get();
       // System.out.println(value==null?"没有这个key":"对应的value是："+value);
    }
}
